package spring.r2dbc;

import org.junit.jupiter.api.Test;
import org.springframework.data.r2dbc.dialect.MySqlDialect;
import org.springframework.data.r2dbc.dialect.R2dbcDialect;
import org.springframework.r2dbc.core.binding.BindMarker;
import org.springframework.r2dbc.core.binding.BindMarkers;
import org.springframework.r2dbc.core.binding.BindMarkersFactory;
import reactor.core.publisher.Mono;

import java.sql.Time;
import java.time.LocalTime;
import java.util.Optional;

public class T3 {
    @Test
    public void t1() {
        Mono.empty().switchIfEmpty(Mono.just(Optional.empty())).map(s -> {
            System.out.println(s);
            return s;
        }).subscribe();
    }

    @Test
    public void t2() {
        R2dbcDialect dialect = new MySqlDialect();
        BindMarkersFactory bmf = dialect.getBindMarkersFactory();
        System.out.println(bmf.identifiablePlaceholders());
        BindMarkers bm = bmf.create();
        BindMarker bm1 = bm.next();
        BindMarker bm2 = bm.next("123");
        System.out.println(bm2.getPlaceholder());
    }

    public static void main(String[] args) {
        LocalTime localTime = LocalTime.now();
        Time time = Time.valueOf(localTime);
        System.out.println(time);

    }
}
